package com.lj.sys.mapper;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lj.mp.standard.StandardMapper;
import com.lj.sys.entity.SysUser;
import com.lj.sys.param.SysUserPageParam;
import com.lj.sys.result.SysUserInfoResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * <p>
 * 系统用户 Mapper 接口
 * </p>
 *
 * @author luojing
 * @since 2024-12-10 14:49:26
 */
@Repository
@Mapper
public interface SysUserMapper extends StandardMapper<SysUser> {

    IPage<SysUserInfoResult> querySysUser(IPage<SysUserInfoResult> page, @Param("param") SysUserPageParam param);

    List<SysUserInfoResult> querySysUser(@Param("param") SysUserPageParam param);

    default SysUserInfoResult querySysUser(Long userId) {
        List<SysUserInfoResult> sysUserInfoResults = querySysUser(new SysUserPageParam().setUserId(userId));
        if (CollUtil.isEmpty(sysUserInfoResults)) {
            return null;
        }
        return sysUserInfoResults.get(0);
    }
}